import XLSX from 'xlsx'

export function export_json_to_excel(table, fileName) {
  //创建book
  let wb = XLSX.utils.book_new();
  //json转sheet
  let ws = XLSX.utils.json_to_sheet(table, {skipHeader: true});
  //设置列宽
  // ws['!cols'] = [
  //   {width: 15},
  //   {width: 15},
  //   {width: 15},
  //   {width: 15},
  //   {width: 10}
  // ];
  //sheet写入book
  XLSX.utils.book_append_sheet(wb, ws, "file");
  //输出
  XLSX.writeFile(wb, `${fileName}.xlsx`);
}
